package mp

import (
	"context"

	"ruikc.com/server/api/internal/db"
	"ruikc.com/server/api/internal/svc"
	"ruikc.com/server/api/internal/types"
	"ruikc.com/server/models"
	xb "xorm.io/builder"

	"github.com/zeromicro/go-zero/core/logx"
)

type InstructorSelectLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewInstructorSelectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InstructorSelectLogic {
	return &InstructorSelectLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *InstructorSelectLogic) InstructorSelect() (resp []types.SelectList, err error) {
	var datas []models.Instructor
	conds := xb.And(xb.Gt{"id": 0})
	db.FindDatasDesc(&datas, conds)
	resp = make([]types.SelectList, 0)
	for _, v := range datas {
		tmp := types.SelectList{
			Value: v.Id,
			Label: v.Name,
		}
		resp = append(resp, tmp)
	}
	return resp, nil
}
